﻿Public Class frmCargaDeuda
    Dim VectorDepartamentoRexpetor(,) As String
    Dim capturaIdGasto As Integer
    Private Sub frmCargaDeuda_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        datosDepCBCargaBlock()
        VectorDepartamentoRexpetor = listadoCargaDepartamento(1)
    End Sub

 
    Private Sub cbBlock_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cbBlock.SelectedIndexChanged
        If IsNumeric(cbBlock.SelectedValue) Then
            cbDepartamento.Text = ""
            txtDeudaI.Text = ""
            txtDeudaA.Text = ""
            VectorDepartamentoRexpetor = listadoCargaDepartamento(cbBlock.SelectedValue)
            lblMensaje.Visible = False

        End If


    End Sub

    Private Sub cbDepartamento_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cbDepartamento.SelectedIndexChanged
        If IsNumeric(cbBlock.SelectedValue) Then
            conectar()


            cmd.Connection = con
            cmd.CommandText = "SELECT ID, SaldoIniDeudaArrastre, SaldoIniDeudaGc FROM  tdepartamento WHERE ID = '" & VectorDepartamentoRexpetor(cbDepartamento.SelectedIndex, 0) & "' AND IDBlock = '" & cbBlock.SelectedValue & "'"
            dr = cmd.ExecuteReader

            If dr.Read Then
                capturaIdGasto = dr(0)
                txtDeudaI.Text = dr(1).ToString
                txtDeudaA.Text = dr(2).ToString

            End If
            dr.Close()
            desconectar()
            lblMensaje.Visible = False
        End If
    End Sub

    Private Sub btnGuardar_Click(sender As Object, e As EventArgs) Handles btnGuardar.Click
        Try
            ModificarGastos(capturaIdGasto, txtDeudaI.Text, txtDeudaA.Text)
        Catch ex As Exception

        End Try

    End Sub

    Private Sub txtDeudaI_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtDeudaI.KeyPress
        If InStr(1, "0123456789,-" & Chr(8), e.KeyChar) = 0 Then
            e.KeyChar = ""
        End If

    
    End Sub


   
    Private Sub txtDeudaA_KeyPress(sender As Object, e As KeyPressEventArgs) Handles txtDeudaA.KeyPress
        If InStr(1, "0123456789,-" & Chr(8), e.KeyChar) = 0 Then
            e.KeyChar = ""
        End If
  
    End Sub
End Class